﻿using Microsoft.AspNet.Identity.EntityFramework;
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Web;
using TGBTech.Web.Models;

namespace TGBTech.Web.Migration
{
    public class Config : DbMigrationsConfiguration<ApplicationDbContext>
    {
        public Config()
        {
            AutomaticMigrationsEnabled = true;
            AutomaticMigrationDataLossAllowed = true;
        }


        protected override void Seed(ApplicationDbContext context)
        {
            this.AddUserAndRoles();
            base.Seed(context);
        }


        bool AddUserAndRoles()
        {
            bool success = false;

            //var idManager = new IdentityManager();
            //success = idManager.CreateRole("User");
            ////if (!success == true) return success;

            //var newUser = new ApplicationUser()
            //{
            //    UserName = "admin",
            //    //FullName="Ad Văn Min"
            //};
            //// Be careful here - you  will need to use a password which will 
            //// be valid under the password rules for the application, 
            //// or the process will abort:
            //success = idManager.CreateUser(newUser, "123456");
            //if (!success) return success;

            //success = idManager.AddUserToRole(newUser.Id, "Admin");
            //success = idManager.AddUserToRole(newUser.Id, "User");
            //if (!success) return success;

            return success;
        }
    }
}